<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style media="screen">
        body {
            background: #000;
        }
        #canvas {
            background: #fff;
            display: block;
            margin: 100px auto;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="800" height="500"></canvas>

    <script type="text/javascript">
        let canvas = document.querySelector('#canvas');
        let ctx = canvas.getContext('2d');

        let img = new Image();
        img.src = './1.jpg';
        img.onload = function() {
            ctx.drawImage(img, 0, 0);
            let data = ctx.getImageData(0, 0, canvas.width, canvas.height)
            console.log(`r: ${data.data[0]}, g: ${data.data[1]}, b: ${data.data[2]}, a: ${data.data[3]}`);
        }
    </script>
</body>
</html>
